1 package activity;
2
3 import java.lang.*;
4 import java.util.*;
5 import javax.swing.*;
6 import java.awt.*;
7 import javax.swing.border.*;
8 import java.awt.event.*;
9 import javax.swing.table.*;
10 import attr.*;
11
12 public class MyProductActivity extends JFrame implements ActionListener {
13 private JPanel panel;
14 private Customer customer;
15 private JFrame activity;
16 private JScrollPane frame;
17 private JTable table;
18 private JButton buttonLogout, buttonBack, buttonCheck;
19 private JLabel title, header, keywordLabel, productNameLabel, productQtLabel, productPriceLabel;
20 private JTextField keywordTF, productNameTF, productQtTF, productPriceTF;
21 public MyProductActivity(JFrame prev, Customer customer) {
22 super("Purchase History");
23
24 this.setSize(Theme.GUI_WIDTH, Theme.GUI_HEIGHT);
25 this.setResizable(false);
26 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
27 this.setLocationRelativeTo(null);
28 this.activity = prev;
29 this.customer = customer;
30
31 panel = new JPanel();
32 panel.setLayout(null);
33 panel.setBackground(Theme.BACKGROUND_PANEL);
34
35 title = new JLabel("Purchase History");
36 title.setBounds(30, 40, 480,75);
37 title.setOpaque(true);
38 title.setBorder(new EmptyBorder(0,20,0,0));
39 title.setFont(Theme.FONT_TITLE);
40 title.setForeground(Theme.COLOR_TITLE);
41 panel.add(title);
42
43 buttonLogout = new JButton("Logout");
44 buttonLogout.setBounds(Theme.GUI_WIDTH-140, 40, Theme.BUTTON_PRIMARY_WIDTH,30);
45 buttonLogout.setFont(Theme.FONT_BUTTON);
46 buttonLogout.setBackground(Color.WHITE);
47 buttonLogout.setForeground(Theme.COLOR_TITLE);
48 buttonLogout.addActionListener(this);
49 panel.add(buttonLogout);
50
51 buttonBack = new JButton("Back");
52 buttonBack.setBounds(Theme.GUI_WIDTH-140, 80, Theme.BUTTON_PRIMARY_WIDTH,30);
53 buttonBack.setFont(Theme.FONT_BUTTON);
54 buttonBack.setBackground(Theme.BACKGROUND_BUTTON_PRIMARY);
55 buttonBack.setForeground(Theme.COLOR_BUTTON_PRIMARY);
56 buttonBack.addActionListener(this);
57 panel.add(buttonBack);
58
59 table = new JTable();
60 table.setModel(customer.myProduct());
61 frame = new JScrollPane(table);
62 frame.setBounds(40,140,600,300);
63 panel.add(frame);
64
65 header = new JLabel();
66 header.setBackground(Theme.BACKGROUND_HEADER);
67 header.setOpaque(true);
68 header.setBounds(0, 0, Theme.GUI_WIDTH, 75);
69 panel.add(header);
70
71 this.add(panel);
72 }
73
74 public void actionPerformed(ActionEvent ae) {
75 if (ae.getSource().equals(buttonLogout)) {
76 this.setVisible(false);
77 new LoginActivity().setVisible(true);
78 }
79 else if (ae.getSource().equals(buttonBack)) {
80 this.setVisible(false);
81 activity.setVisible(true);
82 }
83 else {}
84 }
85
86 private void jTable_ClickMouseClicked(MouseEvent evt) {
87
88 }
89 }